﻿#include <stdio.h>

int is_in_net(unsigned char* ip, unsigned char* netip, unsigned char* mask) {
    for (int i = 0; i < 4; i++) {
        if ((ip[i] & mask[i]) != (netip[i] & mask[i])) {
            return 0; // 不属于该子网
        }
    }
    return 1; // 属于该子网
}

int main() {
    unsigned char ip[4] = { 192, 168, 1, 100 };
    unsigned char netip[4] = { 192, 168, 1, 0 };
    unsigned char mask[4] = { 255, 255, 255, 0 };

    if (is_in_net(ip, netip, mask)) {
        printf("IP 属于该子网\n");
    }
    else {
        printf("IP 不属于该子网\n");
    }

    return 0;
}
